feat(serial): rpc_validate — typed JSON-RPC schema validator (#698)#714
Conversation
#698. Centralizes the rpc.discover host-side validator that today lives ad-hoc on the FastLED Python side. Folded into fbuild-serial (per the project's 'never add a new crate' essential rule) since it sits next to messages.rs's JSON-RPC types and the bring-up orchestrator (#697) is the canonical consumer. What ships: - RpcSchema + MethodDecl — typed shape of rpc.discover's response - parse_schema_response(&str) -> Result<RpcSchema, SchemaParseError> — distinguishes InvalidJson, MissingJsonRpc, MissingMethods, DeviceError variants so callers get actionable failures instead of the cryptic '2 validation errors for RpcSchema: jsonrpc required, methods required' pydantic message FastLED's autoresearch emits today (FastLED/FastLED#3339) - Accepts both canonical envelope shape (result wrapper) AND bare schema shape (no envelope) — different firmwares emit different shapes; pin both - ValidationReport + MethodStatus { Present { params, returns } | Missing } — structured per-method status with the device's signature surfaced when bound - validate_against_expected(&schema, expected) — builds the report; is_passing() iff every expected method is Present - Display renders the actionable diagnostic the issue specifies: 'Expected method 'echo' bound — present (signature: int(int))' / 'Expected method 'ghost' bound — NOT FOUND in device schema.' / 'Device returned N methods total; harness expects M.' 12 unit tests covering: canonical envelope + bare schema parses, MissingJsonRpc / MissingMethods / DeviceError / InvalidJson typed errors, all-present passing report, missing-method failing report, device-method-count surfacing for extras, actionable Display for both pass + fail, empty-expected trivial pass. Out of scope (follow-up): - fetch_schema() doing the actual serial round-trip — lives in the bring-up orchestrator (#697) where the connection is already established - Strict signature checking (today the report surfaces the device signature but doesn't auto-fail; over-fires on int vs int32_t - FastLED's autoresearch migrated to consume this module Closes #698.
|
Warning Review limit reached
More reviews will be available in 20 minutes and 52 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
#698. Centralizes the
rpc.discoverhost-side validator that today lives ad-hoc on the FastLED Python side. Folded intofbuild-serial(per the 'never add a new crate' essential rule) since it sits next tomessages.rs's JSON-RPC types and the bring-up orchestrator (#697) is the canonical consumer.What ships
RpcSchema+MethodDecl— typed shape ofrpc.discover's responseparse_schema_response(&str)— distinguishesInvalidJson,MissingJsonRpc,MissingMethods,DeviceErrorso callers get actionable failures instead of the cryptic '2 validation errors for RpcSchema: jsonrpc required, methods required' pydantic message FastLED autoresearch emits today (fix(autoresearch/lpc): assert DTR=True + VID:PID port detection (#3300) FastLED#3339)ValidationReport+MethodStatus { Present { params, returns } | Missing }— structured per-method statusvalidate_against_expected—is_passing()iff every expected is PresentDisplayrenders the actionable diagnostic the issue specifiesTests — 12 passed
Canonical envelope + bare schema parses, MissingJsonRpc / MissingMethods / DeviceError / InvalidJson typed errors, all-present passing report, missing-method failing report, device-method-count surfacing for extras, actionable Display for both pass + fail, empty-expected trivial pass.
Out of scope (follow-up)
fetch_schema()doing the serial round-trip — lives in the bring-up orchestrator (fbuild-cli: promote bring-up orchestrator to first-class command #697)intvsint32_t)autoresearchmigrated to consume this moduleCloses #698.